<?php
include 'kahlua.ini';
include 'classes/utils/smarty_connect.php';
include_once 'classes/handlers/notasHandler.php';
include_once 'classes/handlers/videosHandler.php';
include_once 'classes/handlers/albumsHandler.php';
include_once 'classes/handlers/ayNoMemesHandler.php';
include_once 'classes/handlers/encuestasHandler.php';
include_once 'classes/handlers/asilotwiteoHandler.php';
include_once 'classes/handlers/masimagenHandler.php';
include_once 'classes/handlers/audiosHandler.php';
include_once 'classes/handlers/comentariosHandler.php';

$notasH = new NotasHandler();
$videosH = new videosHandler();
$albumsH = new albumsHandler();
$aynomemesH = new AyNoMemesHandler();
$encuestasH = new encuestasHandler();
$asilotwiteoH = new asilotwiteoHandler();
$masimagenH = new MasImagenHandler();
$audiosH = new AudiosHandler();
$commentsH = new comentariosHandler();

//right & left sidebars, footer & header
$colRodrigo = $notasH::getColRodrigo();
$topVideo = $videosH::getTopVideo();
$masTiempo = $notasH::getMasTiempo();
$masVistas = $notasH::getMasVistas();
$masComentadas = $notasH::getMasComentadas();
$enResumen = $notasH::getEnResumenFP();
$queFreson = $albumsH::getTop3Albums('queFreson');
$ayNoMemes = $aynomemesH::getTopMeme();
$esquinaNaranja = $notasH::getEsquinaNaranja();
$fresonPolitico = $albumsH::getTop3Albums('fresonPolitico');
$encuesta = $encuestasH::getEncuesta();
$queGuau = $albumsH::getTop3Albums('queGuau');
$gadgets = $notasH::getGadgets();
$asilotwiteo = $asilotwiteoH->getTop();
$masImagen = $masimagenH::getTopMasImagen();

$notaid = $_GET['nota'];
$nota = $notasH::getNota($notaid);

if($nota[0]->getAudioId() != "0"){
    $audioNota = $audiosH::getAudioById($nota[0]->getAudioId());
} else {
    $audioNota = null;
}
if($nota[0]->getVideoId() != "0"){
    $videoNota = $videosH::getMainVideo($nota[0]->getVideoId());
} else {
    $videoNota = null;
}
if($nota[0]->getAlbumId() != "0"){
    $albumNota = $albumsH::getAlbumPorId($nota[0]->getAlbumId());
} else {
    $albumNota = null;
}
$comments = $commentsH::getComentariosPorNotaId($notaid);
//echo '<pre>'; var_dump($nota); exit();

$smarty = new smarty_connect;
$smarty->template_dir = '/projects/masmedio2013/templates';

$smarty->assign('colRodrigo', $colRodrigo[0]);
$smarty->assign('topVideo', $topVideo[0]);
$smarty->assign('masTiempo', $masTiempo[0]);
$smarty->assign('masVistas', $masVistas);
$smarty->assign('masComentadas', $masComentadas);
$smarty->assign('enResumen', $enResumen);
$smarty->assign('queFreson', $queFreson);
$smarty->assign('ayNoMemes', $ayNoMemes[0]);
$smarty->assign('esquinaNaranja', $esquinaNaranja);
$smarty->assign('fresonPolitico', $fresonPolitico);
$smarty->assign('encuesta', $encuesta[0]);
$smarty->assign('queGuau', $queGuau);
$smarty->assign('gadgets', $gadgets);
$smarty->assign('asilotwiteo', $asilotwiteo[0]);
$smarty->assign('masImagen', $masImagen);

$smarty->assign('nota', $nota[0]);
$smarty->assign('audioNota', $audioNota[0]);
$smarty->assign('videoNota', $videoNota[0]);
$smarty->assign('albumNota', $albumNota[0]);
$smarty->assign('comments', $comments);

$smarty->display('/projects/masmedio2013/templates/verNota.tpl');